home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / TGE133.ZIP;1 / INCLUDE / TGE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  30.2 KB  |  595 lines

  1. /*****************************************************************************
  2. *       The Graphics Engine version 1.33                                     *
  3. *                                                                            *
  4. *       The Graphics Engine code and documentation are                       *
  5. *       Copyright (c) 1993-1994 by Matthew Hildebrand; all rights reserved.  *
  6. *                                                                            *
  7. *       Unauthorised usage or modification of any or all of The Graphics     *
  8. *       Engine is strictly prohibited.                                       *
  9. *****************************************************************************/
  10.  
  11. #if !defined(TGEdotH)
  12. #define TGEdotH
  13.  
  14.  
  15.  
  16. /* Comment out this line to disable output modes */
  17. #define TGE_USE_OUTPUT_MODES
  18. /* Comment out this line to disable virtual screens */
  19. #define TGE_USE_VIRTUAL_SCREENS
  20. /* Comment out this line to disable fillRegion() */
  21. #define TGE_USE_REGION_FILLS
  22. /* Comment out this line to disable colourCloseTo() and colourCloseToX() */
  23. #define TGE_USE_COLOUR_APPROXIMATION
  24. /* Comment out this line to disable ellipses and circles */
  25. #define TGE_USE_ELLIPSES
  26. /* Comment out this line to disable images (ie. bitmaps) */
  27. #define TGE_USE_IMAGES
  28. /* Comment out this line to disable putVertLine() and friends */
  29. #define TGE_USE_PUTVERTLINE
  30.  
  31.  
  32.  
  33. /*
  34.  * The basic structure used to store function pointers and mode data.
  35.  */
  36.  
  37. struct GraphDrv {
  38.   /* Non-I/O functions */
  39.   int far (*_initGraphics)(void);
  40.   void far (*_deInitGraphics)(void);
  41.   void far (*_setPaletteReg)(unsigned palReg, unsigned char red, unsigned char green, unsigned char blue);
  42.   void far (*_getPaletteReg)(unsigned palReg, unsigned char far *red, unsigned char far *green, unsigned char far *blue);
  43.   void far (*_setBlockPalette)(unsigned firstReg, unsigned lastReg, void far *data);
  44.   void far (*_getBlockPalette)(unsigned firstReg, unsigned lastReg, void far *data);
  45.   unsigned far (*_colourCloseTo)(unsigned char red, unsigned char green, unsigned char blue);
  46.   unsigned far (*_colourCloseToX)(unsigned char red, unsigned char green, unsigned char blue, unsigned colourExclude);
  47.   unsigned long far (*_imageSize)(int ulx, int uly, int lrx, int lry);
  48.   unsigned long far (*_imageSizeDim)(unsigned wide, unsigned deep);
  49.  
  50.   /* Currently active I/O functions */
  51.   void huge (*_getImage)(int ulx, int uly, int lrx, int lry, void far *image);
  52.   void far (*_getHorizLine)(int y, int xOff, int lineLen, void far *buf);
  53.   void far (*_getVertLine)(int y, int xOff, int lineLen, void far *buf);
  54.   unsigned far (*_getPixel)(int x, int y);
  55.   void huge (*_putImage)(int x, int y, void far *image);
  56.   void huge (*_putImageInv)(int x, int y, void far *image);
  57.   void far (*_putHorizLine)(int y, int xOff, int lineLen, void far *buf);
  58.   void far (*_putHorizLineInv)(int y, int xOff, int lineLen, void far *buf);
  59.   void far (*_putVertLine)(int y, int xOff, int lineLen, void far *buf);
  60.   void far (*_putVertLineInv)(int y, int xOff, int lineLen, void far *buf);
  61.   void far (*_putPixel)(int x, int y, unsigned colour);
  62.   void far (*_line)(int x1, int y1, int x2, int y2, unsigned colour);
  63.   void far (*_horizLine)(int y, int x1, int x2, unsigned colour);
  64.   void far (*_vertLine)(int x, int y1, int y2, unsigned colour);
  65.   void far (*_drawRect)(int ulx, int uly, int lrx, int lry, unsigned colour);
  66.   void far (*_filledRect)(int ulx, int uly, int lrx, int lry, unsigned colour);
  67.   void far (*_clearGraphics)(unsigned colour);
  68.   void far (*_ellipse)(int xc, int yc, int wide, int deep, unsigned colour);
  69.   void far (*_filledEllipse)(int xc, int yc, int wide, int deep, unsigned colour);
  70.   void far (*_circle)(int x, int y, int radius, unsigned colour);
  71.   void far (*_filledCircle)(int x, int y, int radius, unsigned colour);
  72.   void far (*_fillRegion)(int x, int y, unsigned colour);
  73.   void far (*_fillLine)(int y, int x1, int x2, unsigned colour);
  74.  
  75.   /* Input functions */
  76.   void huge (*_getImage_scr)(int ulx, int uly, int lrx, int lry, void far *image);
  77.   void huge (*_getImage_mem)(int ulx, int uly, int lrx, int lry, void far *image);
  78.   void far (*_getHorizLine_scr)(int y, int xOff, int lineLen, void far *buf);
  79.   void far (*_getHorizLine_mem)(int y, int xOff, int lineLen, void far *buf);
  80.   void far (*_getVertLine_scr)(int y, int xOff, int lineLen, void far *buf);
  81.   void far (*_getVertLine_mem)(int y, int xOff, int lineLen, void far *buf);
  82.   unsigned far (*_getPixel_scr)(int x, int y);
  83.   unsigned far (*_getPixel_mem)(int x, int y);
  84.  
  85.   /* Output functions */
  86.   void huge (*_putImage_scr_copy)(int x, int y, void far *image);
  87.   void huge (*_putImage_scr_and) (int x, int y, void far *image);
  88.   void huge (*_putImage_scr_not) (int x, int y, void far *image);
  89.   void huge (*_putImage_scr_or)  (int x, int y, void far *image);
  90.   void huge (*_putImage_scr_xor) (int x, int y, void far *image);
  91.   void huge (*_putImage_mem_copy)(int x, int y, void far *image);
  92.   void huge (*_putImage_mem_and) (int x, int y, void far *image);
  93.   void huge (*_putImage_mem_not) (int x, int y, void far *image);
  94.   void huge (*_putImage_mem_or)  (int x, int y, void far *image);
  95.   void huge (*_putImage_mem_xor) (int x, int y, void far *image);
  96.   void huge (*_putImageInv_scr_copy)(int x, int y, void far *image);
  97.   void huge (*_putImageInv_scr_and) (int x, int y, void far *image);
  98.   void huge (*_putImageInv_scr_not) (int x, int y, void far *image);
  99.   void huge (*_putImageInv_scr_or)  (int x, int y, void far *image);
  100.   void huge (*_putImageInv_scr_xor) (int x, int y, void far *image);
  101.   void huge (*_putImageInv_mem_copy)(int x, int y, void far *image);
  102.   void huge (*_putImageInv_mem_and) (int x, int y, void far *image);
  103.   void huge (*_putImageInv_mem_not) (int x, int y, void far *image);
  104.   void huge (*_putImageInv_mem_or)  (int x, int y, void far *image);
  105.   void huge (*_putImageInv_mem_xor) (int x, int y, void far *image);
  106.   void far (*_putHorizLine_scr_copy)(int y, int xOff, int lineLen, void far *buf);
  107.   void far (*_putHorizLine_scr_and) (int y, int xOff, int lineLen, void far *buf);
  108.   void far (*_putHorizLine_scr_not) (int y, int xOff, int lineLen, void far *buf);
  109.   void far (*_putHorizLine_scr_or)  (int y, int xOff, int lineLen, void far *buf);
  110.   void far (*_putHorizLine_scr_xor) (int y, int xOff, int lineLen, void far *buf);
  111.   void far (*_putHorizLine_mem_copy)(int y, int xOff, int lineLen, void far *buf);
  112.   void far (*_putHorizLine_mem_and) (int y, int xOff, int lineLen, void far *buf);
  113.   void far (*_putHorizLine_mem_not) (int y, int xOff, int lineLen, void far *buf);
  114.   void far (*_putHorizLine_mem_or)  (int y, int xOff, int lineLen, void far *buf);
  115.   void far (*_putHorizLine_mem_xor) (int y, int xOff, int lineLen, void far *buf);
  116.   void far (*_putHorizLineInv_scr_copy)(int y, int xOff, int lineLen, void far *buf);
  117.   void far (*_putHorizLineInv_scr_and) (int y, int xOff, int lineLen, void far *buf);
  118.   void far (*_putHorizLineInv_scr_not) (int y, int xOff, int lineLen, void far *buf);
  119.   void far (*_putHorizLineInv_scr_or)  (int y, int xOff, int lineLen, void far *buf);
  120.   void far (*_putHorizLineInv_scr_xor) (int y, int xOff, int lineLen, void far *buf);
  121.   void far (*_putHorizLineInv_mem_copy)(int y, int xOff, int lineLen, void far *buf);
  122.   void far (*_putHorizLineInv_mem_and) (int y, int xOff, int lineLen, void far *buf);
  123.   void far (*_putHorizLineInv_mem_not) (int y, int xOff, int lineLen, void far *buf);
  124.   void far (*_putHorizLineInv_mem_or)  (int y, int xOff, int lineLen, void far *buf);
  125.   void far (*_putHorizLineInv_mem_xor) (int y, int xOff, int lineLen, void far *buf);
  126.   void far (*_putVertLine_scr_copy)(int y, int xOff, int lineLen, void far *buf);
  127.   void far (*_putVertLine_scr_and) (int y, int xOff, int lineLen, void far *buf);
  128.   void far (*_putVertLine_scr_not) (int y, int xOff, int lineLen, void far *buf);
  129.   void far (*_putVertLine_scr_or)  (int y, int xOff, int lineLen, void far *buf);
  130.   void far (*_putVertLine_scr_xor) (int y, int xOff, int lineLen, void far *buf);
  131.   void far (*_putVertLine_mem_copy)(int y, int xOff, int lineLen, void far *buf);
  132.   void far (*_putVertLine_mem_and) (int y, int xOff, int lineLen, void far *buf);
  133.   void far (*_putVertLine_mem_not) (int y, int xOff, int lineLen, void far *buf);
  134.   void far (*_putVertLine_mem_or)  (int y, int xOff, int lineLen, void far *buf);
  135.   void far (*_putVertLine_mem_xor) (int y, int xOff, int lineLen, void far *buf);
  136.   void far (*_putVertLineInv_scr_copy)(int y, int xOff, int lineLen, void far *buf);
  137.   void far (*_putVertLineInv_scr_and) (int y, int xOff, int lineLen, void far *buf);
  138.   void far (*_putVertLineInv_scr_not) (int y, int xOff, int lineLen, void far *buf);
  139.   void far (*_putVertLineInv_scr_or)  (int y, int xOff, int lineLen, void far *buf);
  140.   void far (*_putVertLineInv_scr_xor) (int y, int xOff, int lineLen, void far *buf);
  141.   void far (*_putVertLineInv_mem_copy)(int y, int xOff, int lineLen, void far *buf);
  142.   void far (*_putVertLineInv_mem_and) (int y, int xOff, int lineLen, void far *buf);
  143.   void far (*_putVertLineInv_mem_not) (int y, int xOff, int lineLen, void far *buf);
  144.   void far (*_putVertLineInv_mem_or)  (int y, int xOff, int lineLen, void far *buf);
  145.   void far (*_putVertLineInv_mem_xor) (int y, int xOff, int lineLen, void far *buf);
  146.   void far (*_putPixel_scr_copy)(int x, int y, unsigned colour);
  147.   void far (*_putPixel_scr_and) (int x, int y, unsigned colour);
  148.   void far (*_putPixel_scr_not) (int x, int y, unsigned colour);
  149.   void far (*_putPixel_scr_or)  (int x, int y, unsigned colour);
  150.   void far (*_putPixel_scr_xor) (int x, int y, unsigned colour);
  151.   void far (*_putPixel_mem_copy)(int x, int y, unsigned colour);
  152.   void far (*_putPixel_mem_and) (int x, int y, unsigned colour);
  153.   void far (*_putPixel_mem_not) (int x, int y, unsigned colour);
  154.   void far (*_putPixel_mem_or)  (int x, int y, unsigned colour);
  155.   void far (*_putPixel_mem_xor) (int x, int y, unsigned colour);
  156.   void far (*_line_scr_copy)(int x1, int y1, int x2, int y2, unsigned colour);
  157.   void far (*_line_scr_and) (int x1, int y1, int x2, int y2, unsigned colour);
  158.   void far (*_line_scr_not) (int x1, int y1, int x2, int y2, unsigned colour);
  159.   void far (*_line_scr_or)  (int x1, int y1, int x2, int y2, unsigned colour);
  160.   void far (*_line_scr_xor) (int x1, int y1, int x2, int y2, unsigned colour);
  161.   void far (*_line_mem_copy)(int x1, int y1, int x2, int y2, unsigned colour);
  162.   void far (*_line_mem_and) (int x1, int y1, int x2, int y2, unsigned colour);
  163.   void far (*_line_mem_not) (int x1, int y1, int x2, int y2, unsigned colour);
  164.   void far (*_line_mem_or)  (int x1, int y1, int x2, int y2, unsigned colour);
  165.   void far (*_line_mem_xor) (int x1, int y1, int x2, int y2, unsigned colour);
  166.   void far (*_horizLine_scr_copy)(int y, int x1, int x2, unsigned colour);
  167.   void far (*_horizLine_scr_and) (int y, int x1, int x2, unsigned colour);
  168.   void far (*_horizLine_scr_not) (int y, int x1, int x2, unsigned colour);
  169.   void far (*_horizLine_scr_or)  (int y, int x1, int x2, unsigned colour);
  170.   void far (*_horizLine_scr_xor) (int y, int x1, int x2, unsigned colour);
  171.   void far (*_horizLine_mem_copy)(int y, int x1, int x2, unsigned colour);
  172.   void far (*_horizLine_mem_and) (int y, int x1, int x2, unsigned colour);
  173.   void far (*_horizLine_mem_not) (int y, int x1, int x2, unsigned colour);
  174.   void far (*_horizLine_mem_or)  (int y, int x1, int x2, unsigned colour);
  175.   void far (*_horizLine_mem_xor) (int y, int x1, int x2, unsigned colour);
  176.   void far (*_vertLine_scr_copy)(int x, int y1, int y2, unsigned colour);
  177.   void far (*_vertLine_scr_and) (int x, int y1, int y2, unsigned colour);
  178.   void far (*_vertLine_scr_not) (int x, int y1, int y2, unsigned colour);
  179.   void far (*_vertLine_scr_or)  (int x, int y1, int y2, unsigned colour);
  180.   void far (*_vertLine_scr_xor) (int x, int y1, int y2, unsigned colour);
  181.   void far (*_vertLine_mem_copy)(int x, int y1, int y2, unsigned colour);
  182.   void far (*_vertLine_mem_and) (int x, int y1, int y2, unsigned colour);
  183.   void far (*_vertLine_mem_not) (int x, int y1, int y2, unsigned colour);
  184.   void far (*_vertLine_mem_or)  (int x, int y1, int y2, unsigned colour);
  185.   void far (*_vertLine_mem_xor)(int x, int y1, int y2, unsigned colour);
  186.   void far (*_drawRect_scr_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  187.   void far (*_drawRect_scr_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  188.   void far (*_drawRect_scr_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  189.   void far (*_drawRect_scr_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  190.   void far (*_drawRect_scr_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  191.   void far (*_drawRect_mem_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  192.   void far (*_drawRect_mem_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  193.   void far (*_drawRect_mem_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  194.   void far (*_drawRect_mem_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  195.   void far (*_drawRect_mem_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  196.   void far (*_filledRect_scr_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  197.   void far (*_filledRect_scr_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  198.   void far (*_filledRect_scr_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  199.   void far (*_filledRect_scr_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  200.   void far (*_filledRect_scr_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  201.   void far (*_filledRect_mem_copy)(int ulx, int uly, int lrx, int lry, unsigned colour);
  202.   void far (*_filledRect_mem_and) (int ulx, int uly, int lrx, int lry, unsigned colour);
  203.   void far (*_filledRect_mem_not) (int ulx, int uly, int lrx, int lry, unsigned colour);
  204.   void far (*_filledRect_mem_or)  (int ulx, int uly, int lrx, int lry, unsigned colour);
  205.   void far (*_filledRect_mem_xor) (int ulx, int uly, int lrx, int lry, unsigned colour);
  206.   void far (*_clearGraphics_scr_copy)(unsigned colour);
  207.   void far (*_clearGraphics_scr_and) (unsigned colour);
  208.   void far (*_clearGraphics_scr_not) (unsigned colour);
  209.   void far (*_clearGraphics_scr_or)  (unsigned colour);
  210.   void far (*_clearGraphics_scr_xor) (unsigned colour);
  211.   void far (*_clearGraphics_mem_copy)(unsigned colour);
  212.   void far (*_clearGraphics_mem_and) (unsigned colour);
  213.   void far (*_clearGraphics_mem_not) (unsigned colour);
  214.   void far (*_clearGraphics_mem_or)  (unsigned colour);
  215.   void far (*_clearGraphics_mem_xor) (unsigned colour);
  216.   void far (*_ellipse_scr_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  217.   void far (*_ellipse_scr_and) (int xc, int yc, int wide, int deep, unsigned colour);
  218.   void far (*_ellipse_scr_not) (int xc, int yc, int wide, int deep, unsigned colour);
  219.   void far (*_ellipse_scr_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  220.   void far (*_ellipse_scr_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  221.   void far (*_ellipse_mem_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  222.   void far (*_ellipse_mem_and) (int xc, int yc, int wide, int deep, unsigned colour);
  223.   void far (*_ellipse_mem_not) (int xc, int yc, int wide, int deep, unsigned colour);
  224.   void far (*_ellipse_mem_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  225.   void far (*_ellipse_mem_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  226.   void far (*_filledEllipse_scr_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  227.   void far (*_filledEllipse_scr_and) (int xc, int yc, int wide, int deep, unsigned colour);
  228.   void far (*_filledEllipse_scr_not) (int xc, int yc, int wide, int deep, unsigned colour);
  229.   void far (*_filledEllipse_scr_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  230.   void far (*_filledEllipse_scr_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  231.   void far (*_filledEllipse_mem_copy)(int xc, int yc, int wide, int deep, unsigned colour);
  232.   void far (*_filledEllipse_mem_and) (int xc, int yc, int wide, int deep, unsigned colour);
  233.   void far (*_filledEllipse_mem_not) (int xc, int yc, int wide, int deep, unsigned colour);
  234.   void far (*_filledEllipse_mem_or)  (int xc, int yc, int wide, int deep, unsigned colour);
  235.   void far (*_filledEllipse_mem_xor) (int xc, int yc, int wide, int deep, unsigned colour);
  236.   void far (*_circle_scr_copy)(int x, int y, int radius, unsigned colour);
  237.   void far (*_circle_scr_and) (int x, int y, int radius, unsigned colour);
  238.   void far (*_circle_scr_not) (int x, int y, int radius, unsigned colour);
  239.   void far (*_circle_scr_or)  (int x, int y, int radius, unsigned colour);
  240.   void far (*_circle_scr_xor) (int x, int y, int radius, unsigned colour);
  241.   void far (*_circle_mem_copy)(int x, int y, int radius, unsigned colour);
  242.   void far (*_circle_mem_and) (int x, int y, int radius, unsigned colour);
  243.   void far (*_circle_mem_not) (int x, int y, int radius, unsigned colour);
  244.   void far (*_circle_mem_or)  (int x, int y, int radius, unsigned colour);
  245.   void far (*_circle_mem_xor) (int x, int y, int radius, unsigned colour);
  246.   void far (*_filledCircle_scr_copy)(int x, int y, int radius, unsigned colour);
  247.   void far (*_filledCircle_scr_and) (int x, int y, int radius, unsigned colour);
  248.   void far (*_filledCircle_scr_not) (int x, int y, int radius, unsigned colour);
  249.   void far (*_filledCircle_scr_or)  (int x, int y, int radius, unsigned colour);
  250.   void far (*_filledCircle_scr_xor) (int x, int y, int radius, unsigned colour);
  251.   void far (*_filledCircle_mem_copy)(int x, int y, int radius, unsigned colour);
  252.   void far (*_filledCircle_mem_and) (int x, int y, int radius, unsigned colour);
  253.   void far (*_filledCircle_mem_not) (int x, int y, int radius, unsigned colour);
  254.   void far (*_filledCircle_mem_or)  (int x, int y, int radius, unsigned colour);
  255.   void far (*_filledCircle_mem_xor) (int x, int y, int radius, unsigned colour);
  256.   void far (*_fillRegion_scr_copy)(int x, int y, unsigned colour);
  257.   void far (*_fillRegion_scr_and) (int x, int y, unsigned colour);
  258.   void far (*_fillRegion_scr_not) (int x, int y, unsigned colour);
  259.   void far (*_fillRegion_scr_or)  (int x, int y, unsigned colour);
  260.   void far (*_fillRegion_scr_xor) (int x, int y, unsigned colour);
  261.   void far (*_fillRegion_mem_copy)(int x, int y, unsigned colour);
  262.   void far (*_fillRegion_mem_and) (int x, int y, unsigned colour);
  263.   void far (*_fillRegion_mem_not) (int x, int y, unsigned colour);
  264.   void far (*_fillRegion_mem_or)  (int x, int y, unsigned colour);
  265.   void far (*_fillRegion_mem_xor) (int x, int y, unsigned colour);
  266.   void far (*_fillLine_scr_copy)(int y, int x1, int x2, unsigned colour);
  267.   void far (*_fillLine_scr_and) (int y, int x1, int x2, unsigned colour);
  268.   void far (*_fillLine_scr_not) (int y, int x1, int x2, unsigned colour);
  269.   void far (*_fillLine_scr_or)  (int y, int x1, int x2, unsigned colour);
  270.   void far (*_fillLine_scr_xor) (int y, int x1, int x2, unsigned colour);
  271.   void far (*_fillLine_mem_copy)(int y, int x1, int x2, unsigned colour);
  272.   void far (*_fillLine_mem_and) (int y, int x1, int x2, unsigned colour);
  273.   void far (*_fillLine_mem_not) (int y, int x1, int x2, unsigned colour);
  274.   void far (*_fillLine_mem_or)  (int y, int x1, int x2, unsigned colour);
  275.   void far (*_fillLine_mem_xor) (int y, int x1, int x2, unsigned colour);
  276.  
  277.   /* Driver data */
  278.   short scrnMaxX, scrnMaxY;                 /* physical screen dimensions */
  279.   unsigned short maxColour;                 /* maximum colour number */
  280.   unsigned short xRatio, yRatio;            /* screen aspect ratio */
  281.   unsigned short bitsPerPixel;              /* bits per pixel */
  282.   short inMaxX, inMaxY;                     /* input screen dimensions */
  283.   short outMaxX, outMaxY;                   /* output screen dimensions */
  284.   unsigned short inScreenWide, outScreenWide; /* needed for virtual screens */
  285.   short inViewportULX, inViewportULY;       /* input viewport coords */
  286.   short inViewportLRX, inViewportLRY;
  287.   short outViewportULX, outViewportULY;     /* output viewport coords */
  288.   short outViewportLRX, outViewportLRY;
  289.   void far *inAddr;                         /* current input address */
  290.   void far *outAddr;                        /* current output address */
  291.   void far *scrAddr;                        /* screen address */
  292. };
  293.  
  294.  
  295.  
  296. /*
  297.  * Note that this C/C++ bit might not work properly with your compiler.  If
  298.  * you are using C++ and your linker reports that these functions are not
  299.  * found, try explicitly forcing the extern "C" syntax by removing these
  300.  * preprocessor directives.
  301.  */
  302.  
  303. #if defined(__cplusplus)
  304. extern "C" {
  305. #endif
  306.  
  307. /* Load/unload routines */
  308. int TGE_loadGraphDriver(char *filename);
  309. void TGE_unloadGraphDriver(void);
  310.  
  311. /* Virtual/real screen routines */
  312. #if defined(TGE_USE_VIRTUAL_SCREENS)
  313.   void TGE_setGraphicsInputAddr(void far *addr);
  314.   void TGE_setGraphicsOutputAddr(void far *addr);
  315.   void TGE_setGraphicsAddr(void far *addr);
  316.   void far *TGE_getGraphicsInputAddr(void);
  317.   void far *TGE_getGraphicsOutputAddr(void);
  318.   void far *TGE_makeVirtScreen(unsigned wide, unsigned deep);
  319. #endif
  320.  
  321. /* Output mode control routine */
  322. #if defined(TGE_USE_OUTPUT_MODES)
  323.   void TGE_setOutputMode(int mode);
  324. #endif
  325.  
  326. /* Viewport routines */
  327. void TGE_setInputViewport(int ulx, int uly, int lrx, int lry);
  328. void TGE_setOutputViewport(int ulx, int uly, int lrx, int lry);
  329. void TGE_setViewports(int ulx, int uly, int lrx, int lry);
  330. void TGE_getInputViewport(int *ulx, int *uly, int *lrx, int *lry);
  331. void TGE_getOutputViewport(int *ulx, int *uly, int *lrx, int *lry);
  332.  
  333. /* Clipping routines */
  334. int TGE_clipLine(int *x1, int *y1, int *x2, int *y2);
  335. int TGE_clipRect(int *ulx, int *uly, int *lrx, int *lry);
  336.  
  337. /* Scale bitmap */
  338. void TGE_scaleBitmap(void *srcImage, unsigned newWide, unsigned newDeep,
  339.     void *destImage);
  340.  
  341. /* Palette routines */
  342. int TGE_fadePalette(unsigned step, void *inPal, void *outPal, void *targetPal);
  343. void TGE_greyPalette(void *inPal, void *outPal);
  344. void TGE_rotatePalette(int howMuch, void *inPal, void *outPal);
  345.  
  346. /* RAW/PAL file routines */
  347. void *TGE_loadRawFile(char *filename);
  348. int TGE_displayRawFile(int x, int y, char *filename);
  349. void *TGE_loadPalFile(char *filename, void *addr);
  350. int TGE_saveRawFile(char *filename, void *image);
  351. int TGE_savePalFile(char *filename, void *pal);
  352.  
  353. /* PCX file routines */
  354. void *TGE_loadPcxFile(char *filename, void *palette);
  355. int TGE_displayPcxFile(int x, int y, char *filename);
  356. void *TGE_loadPcxFilePal(char *filename, void *addr);
  357.  
  358. /* Colour replacement routine */
  359. void TGE_replaceColour(int ulx, int uly, int lrx, int lry, unsigned oldColour, unsigned newColour);
  360.  
  361. #if defined(__cplusplus)
  362. };
  363. #endif
  364.  
  365.  
  366.  
  367. /*
  368.  * Declare the structure used by the system so that programs can access it.
  369.  */
  370.  
  371. extern struct GraphDrv far *TGEsys;
  372.  
  373.  
  374.  
  375. /*
  376.  * The function names of TGE's functions are defined here.  Since they are
  377.  * really just macros pretending to be functions, you can easily change
  378.  * their names here if you don't like the default ones.
  379.  */
  380.  
  381. #define initGraphics        (TGEsys->_initGraphics)
  382. #define deInitGraphics        (TGEsys->_deInitGraphics)
  383. #if defined(TGE_USE_IMAGES)
  384.   #define putImage              (TGEsys->_putImage)
  385.   #define putImageInv           (TGEsys->_putImageInv)
  386.   #define getImage              (TGEsys->_getImage)
  387. #endif
  388. #define getHorizLine            (TGEsys->_getHorizLine)
  389. #define getLine                 getHorizLine
  390. #define putHorizLine            (TGEsys->_putHorizLine)
  391. #define putLine                 putHorizLine
  392. #define putHorizLineInv         (TGEsys->_putHorizLineInv)
  393. #define putLineInv              putHorizLineInv
  394. #if defined(TGE_USE_PUTVERTLINE)
  395.   #define getVertLine           (TGEsys->_getVertLine)
  396.   #define putVertLine           (TGEsys->_putVertLine)
  397.   #define putVertLineInv        (TGEsys->_putVertLineInv)
  398. #endif
  399. #if defined(TGE_USE_IMAGES)
  400.   #define imageSize             (TGEsys->_imageSize)
  401.   #define imageSizeDim          (TGEsys->_imageSizeDim)
  402. #endif
  403. #define putPixel                (TGEsys->_putPixel)
  404. #define getPixel        (TGEsys->_getPixel)
  405. #define line            (TGEsys->_line)
  406. #define horizLine        (TGEsys->_horizLine)
  407. #define vertLine        (TGEsys->_vertLine)
  408. #define drawRect        (TGEsys->_drawRect)
  409. #define filledRect        (TGEsys->_filledRect)
  410. #define setPaletteReg        (TGEsys->_setPaletteReg)
  411. #define getPaletteReg        (TGEsys->_getPaletteReg)
  412. #define setBlockPalette        (TGEsys->_setBlockPalette)
  413. #define getBlockPalette        (TGEsys->_getBlockPalette)
  414. #define clearGraphics        (TGEsys->_clearGraphics)
  415. #if defined(TGE_USE_ELLIPSES)
  416.   #define ellipse               (TGEsys->_ellipse)
  417.   #define filledEllipse         (TGEsys->_filledEllipse)
  418.   #define circle                (TGEsys->_circle)
  419.   #define filledCircle          (TGEsys->_filledCircle)
  420. #endif
  421. #if defined(TGE_USE_REGION_FILLS)
  422.   #define fillRegion        (TGEsys->_fillRegion)
  423. #endif
  424. #if defined(TGE_USE_COLOUR_APPROXIMATION)
  425.   #define colourCloseTo        (TGEsys->_colourCloseTo)
  426.   #define colourCloseToX        (TGEsys->_colourCloseToX)
  427.   #define colorCloseTo          (TGEsys->_colourCloseTo)
  428.   #define colorCloseToX         (TGEsys->_colourCloseToX)
  429. #endif
  430. #define fillLine                (TGEsys->_fillLine)
  431.  
  432. #define loadGraphDriver       TGE_loadGraphDriver
  433. #define unloadGraphDriver     TGE_unloadGraphDriver
  434.  
  435. #if defined(TGE_USE_VIRTUAL_SCREENS)
  436.   #define setGraphicsOutputAddr TGE_setGraphicsOutputAddr /* set outputs */
  437.   #define setGraphicsInputAddr  TGE_setGraphicsInputAddr  /* set input   */
  438.   #define setGraphicsAddr       TGE_setGraphicsAddr       /* set I/O     */
  439.   #define makeVirtScreen        TGE_makeVirtScreen        /* make virtual screen */
  440.   #define getGraphicsOutputAddr TGE_getGraphicsOutputAddr /* set output  */
  441.   #define getGraphicsInputAddr  TGE_getGraphicsInputAddr  /* set input   */
  442. #endif
  443.  
  444. #if defined(TGE_USE_OUTPUT_MODES)
  445.   #define setGraphicsOutputMode   TGE_setOutputMode         /* output mode */
  446. #endif
  447.  
  448. #define setOutputViewport    TGE_setOutputViewport      /* viewports */
  449. #define setInputViewport           TGE_setInputViewport
  450. #define setViewports            TGE_setViewports
  451. #define setViewport        TGE_setViewports
  452. #define getOutputViewport    TGE_getOutputViewport
  453. #define getInputViewport          TGE_getInputViewport
  454. #define getViewport        TGE_getOutputViewport
  455.  
  456. #define clipLine        TGE_clipLine          /* clipping */
  457. #define clipRect                TGE_clipRect
  458. #define clipFilledRect          TGE_clipRect
  459. #define clipInputPoint          TGE_clipInputPoint
  460. #define clipOutputPoint         TGE_clipOutputPoint
  461. #define clipPoint               TGE_clipPoint
  462. #define pointOnScreen           TGE_pointOnScreen
  463.  
  464. #define scaleBitmap             TGE_scaleBitmap           /* scaling */
  465.  
  466. #define fadePalette             TGE_fadePalette           /* palette */
  467. #define greyPalette             TGE_greyPalette
  468. #define rotatePalette           TGE_rotatePalette
  469. #define promotePalette          TGE_promotePalette
  470. #define demotePalette           TGE_demotePalette
  471.  
  472. #define loadRawFile             TGE_loadRawFile           /* image files */
  473. #define displayRawFile          TGE_displayRawFile
  474. #define loadPalFile             TGE_loadPalFile
  475. #define saveRawFile             TGE_saveRawFile
  476. #define savePalFile             TGE_savePalFile
  477. #define loadPcxFile             TGE_loadPcxFile
  478. #define displayPcxFile          TGE_displayPcxFile
  479. #define loadPcxFilePal          TGE_loadPcxFilePal
  480.  
  481. #define replaceColour           TGE_replaceColour         /* colour replacing */
  482. #define replaceColor            TGE_replaceColour
  483.  
  484.  
  485.  
  486. /*
  487.  * These macros provide easy access to important mode information in the
  488.  * TGE system structure.
  489.  */
  490.  
  491. #define INMAXX            (TGEsys->inMaxX)
  492. #define INMAXY            (TGEsys->inMaxY)
  493. #define OUTMAXX            (TGEsys->outMaxX)
  494. #define OUTMAXY            (TGEsys->outMaxY)
  495. #define MAXCOLOUR        (TGEsys->maxColour)
  496. #define MAXCOLOR                (TGEsys->maxColour)
  497. #define XRATIO                  (TGEsys->xRatio)
  498. #define YRATIO            (TGEsys->yRatio)
  499. #define INVIEWPORTULX        (TGEsys->inViewportULX)
  500. #define INVIEWPORTULY        (TGEsys->inViewportULY)
  501. #define INVIEWPORTLRX        (TGEsys->inViewportLRX)
  502. #define INVIEWPORTLRY        (TGEsys->inViewportLRY)
  503. #define OUTVIEWPORTULX        (TGEsys->outViewportULX)
  504. #define OUTVIEWPORTULY        (TGEsys->outViewportULY)
  505. #define OUTVIEWPORTLRX        (TGEsys->outViewportLRX)
  506. #define OUTVIEWPORTLRY        (TGEsys->outViewportLRY)
  507. #define SCREENMAXX        (TGEsys->scrnMaxX)
  508. #define SCREENMAXY        (TGEsys->scrnMaxY)
  509. #define MAXX            (TGEsys->outMaxX)
  510. #define MAXY            (TGEsys->outMaxY)
  511. #define VIEWPORTULX        (TGEsys->outViewportULX)
  512. #define VIEWPORTULY        (TGEsys->outViewportULY)
  513. #define VIEWPORTLRX        (TGEsys->outViewportLRX)
  514. #define VIEWPORTLRY        (TGEsys->outViewportLRY)
  515.  
  516.  
  517.  
  518. /*
  519.  * These macros are for the various output modes.
  520.  */
  521.  
  522. #if defined(TGE_USE_OUTPUT_MODES)
  523.   #define TGE_COPY_PUT          0
  524.   #define TGE_AND_PUT           1
  525.   #define TGE_NOT_PUT           2
  526.   #define TGE_OR_PUT            3
  527.   #define TGE_XOR_PUT           4
  528. #endif
  529.  
  530.  
  531.  
  532. /*
  533.  * These macros are the return codes from loadGraphDriver().
  534.  */
  535.  
  536. #define TGE_SUCCESS     0        /* driver loaded successfully */
  537. #define TGE_OPEN_ERR    -1        /* error opening given file */
  538. #define TGE_FORMAT_ERR    -2        /* file is not a TGE driver */
  539. #define TGE_ALLOC_ERR    -3            /* error allocating memory */
  540. #define TGE_FILE_ERR    -4        /* file I/O error */
  541.  
  542.  
  543.  
  544. /*
  545.  * Point clipping routines.
  546.  */
  547.  
  548. #define TGE_pointOnScreen(x,y) \
  549.   ((x>=0) && (x<=TGEsys->scrnMaxX) && (y>=0) && (y<=TGEsys->scrnMaxY))
  550. #define TGE_clipInputPoint(x,y) \
  551.   ((x>=INVIEWPORTULX) && (x<=INVIEWPORTLRX) && \
  552.    (y>=INVIEWPORTULY) && (y<=INVIEWPORTLRY))
  553. #define TGE_clipOutputPoint(x,y) \
  554.   ((x>=OUTVIEWPORTULX) && (x<=OUTVIEWPORTLRX) && \
  555.    (y>=OUTVIEWPORTULY) && (y<=OUTVIEWPORTLRY))
  556. #define TGE_clipPoint(x,y) \
  557.   TGE_clipOutputPoint(x,y)
  558.  
  559.  
  560.  
  561. /*
  562.  * Image dimension macros.
  563.  */
  564.  
  565. #if defined(TGE_USE_IMAGES)
  566.   #define imageWidth(image)     ((unsigned*)image)[0]
  567.   #define imageHeight(image)    ((unsigned*)image)[1]
  568. #endif
  569.  
  570.  
  571.  
  572. /*
  573.  * Ease the use of TGE with different compilers by standardizing #defines.
  574.  */
  575.  
  576. #if defined(__TURBOC__)
  577.   #define ENABLE_INTERRUPTS     enable()
  578.   #define DISABLE_INTERRUPTS    disable()
  579.   #define GENERATE_INTERRUPT(i) geninterrupt(i)
  580. #else
  581.   #define ENABLE_INTERRUPTS     asm cli
  582.   #define DISABLE_INTERRUPTS    asm sti
  583.   #define GENERATE_INTERRUPT(i) asm int i
  584. #endif
  585.  
  586. #if !defined(__TURBOC__)
  587.   #define MK_FP(seg,ofs)        (((unsigned long)seg<<16) | ofs)
  588.   #define FP_SEG(fp)            ((unsigned short)(seg>>16))
  589.   #define FP_OFF(fp)            ((unsigned long)fp & 0xFFFF)
  590. #endif
  591.  
  592.  
  593.  
  594. #endif
  595.